import { defineStore } from 'pinia';
import { store } from '@/store';

interface LocaleState {
	marqueeTool : string | number;
	layerName : string;
	echartShowTwo : boolean;
	echartShowWeek : boolean;
	echartShowYear : boolean;
	ownMap : any;
	/** 点击地图的坐标点, BMap.Point, 控制是否显示道路基础信息弹窗 */
	showPop : object | string;

	/** 道路规划等级弹窗是否显示 */
	showPolyline : Boolean;
	//点击地图时 同步左侧道路信息
	showRoadBaseInfo : any;
	slcList : Boolean;
}

export const useMapStore = defineStore({
	id: 'map',
	state: () : LocaleState => ({
		marqueeTool: '',
		layerName: '',
		echartShowTwo: false,
		echartShowWeek: false,
		echartShowYear: false,
		ownMap: null,
		showPop: {},
		showPolyline: false,
		slcList: true,
		showRoadBaseInfo: null,
	}),
	getters: {
		getMarqueeTool(state) {
			return state.marqueeTool;
		},
		getShowPolyline(state) {
			return state.showPolyline;
		},
		// getShowRoadBaseInfo(state){
		//   return state.showRoadBaseInfo;
		// },
	},
	actions: {
		setSlcList(st) {
			// console.log(st, 'stt');
			this.slcList = st
		},
		setShowPolyline(val) {
			// console.log(val, 'hjsojd');

			this.showPolyline = val;
		},
		setShowPop(obj) {
			this.showPop = obj;
		},
		setOwnMap(map) {
			// console.log(map);
			this.ownMap = map;
		},
		setShowRoadBaseInfo(datam) {
			// console.log("datam=====b", datam);
			this.showRoadBaseInfo = datam;
		},
		setMarqueeTool(marqueeTool) {
			console.log(marqueeTool);
			this.marqueeTool = marqueeTool;
		},
		mapChangeOk(echartShowTwo) {
			this.echartShowTwo = echartShowTwo;
		},
		mapChangeWeek(echartShowWeek) {
			this.echartShowWeek = echartShowWeek;
		},
		mapChangeYear(echartShowYear) {
			this.echartShowYear = echartShowYear;
		},
		setLayerView(layerName) {
			console.log(layerName);
			this.layerName = layerName;
		},
	},
});

// Need to be used outside the setup
export function useMapStoreWithOut() {
	return useMapStore(store);
}